import 'package:flutter/material.dart';
import 'package:flutter_shop/pages/home/tab_Index/index.dart';
import 'package:flutter_shop/pages/home/tab_Info/index.dart';
import 'package:flutter_shop/pages/home/tab_profile/index.dart';
import 'package:flutter_shop/pages/home/tab_search/index.dart';
import 'package:flutter_shop/widgets/page_content.dart';

class Index extends StatefulWidget {
  @override
  _IndexState createState() => _IndexState();
}

class _IndexState extends State<Index> {
  List<Widget> tabsList = [TabIndex(), TabSeatch(), TabInfo(), TabProfile()];

  List<BottomNavigationBarItem> barItemList = [
    BottomNavigationBarItem(icon: Icon(Icons.home), label: '首页'),
    BottomNavigationBarItem(icon: Icon(Icons.search), label: '搜索'),
    BottomNavigationBarItem(icon: Icon(Icons.info), label: '资讯'),
    BottomNavigationBarItem(icon: Icon(Icons.account_circle), label: '我的'),
  ];

  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: tabsList[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        items: barItemList,
        unselectedItemColor: Colors.grey,
        selectedItemColor: Colors.green,
        currentIndex: _currentIndex,
        onTap: (int index) {
          setState(() {
            _currentIndex = index;
          });
        },
      ),
    );
  }
}
